<?php
namespace app\api\service;
use think\Controller;

/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/5/26 0026
 * Time: 15:40
 */

class Zb extends Controller {

    public static function create_zb_order($param) {
        try {
            $data = [
                'order_sn' => 'ZB' . date('YmdHis') . rand(1000, 9999),
                'price' => $param['price'],
                'num' => $param['num'],
                'openid' => $param['openid'],
                'nickname' => $param['nickname'],
                'headimgurl' => $param['headimgurl'],
                'video_id' => $param['video_id']
            ];

            $model = model('order_zb');
            $model->save($data);
            // 创建成功  返回最后一条数据
            $order = $model->get(['id' => $model->id]);
            return api_return(200, $order);

        } catch (\Exception $e) {
            return api_return(0, '', $e->getMessage());
        }
    }
}